# @coding utf-8
# @author errorcpp@qq.com


function(xchecking_git_env result)
	message(STATUS "checking git env")
	execute_process(COMMAND git --version 
		RESULT_VARIABLE result
		OUTPUT_QUIET
		ERROR_QUIET)
	if(${result} EQUAL 0)
		message(STATUS "git is ready")
	else()
		message(WARNING "git is not usable, the project maybe can not build !")
	endif()
endfunction()

function(xcheck_and_init_submodule submodule_name)
	# 设置xcmake_util目录路径
	set(submodule_path "${CMAKE_SOURCE_DIR}/${submodule_name}")
	message(STATUS "checking xcmake_util: " ${submodule_path})
	if(EXISTS ${submodule_path})
		message(STATUS "${submodule_name} is ready")
	else()
		message(STATUS "downloading ${submodule_name}")
		# 当前是以submodule方式加入的
		#execute_process(COMMAND git clone git@gitee.com:enic/xcmake_util.git)
		#execute_process(COMMAND git submodule update --remote xcmake_util) 需要用 ../../../../xcmake_util
		execute_process(COMMAND git submodule update --init)
		message(STATUS "finish downloading ${submodule_name}")
	endif()
endfunction()